package src.entities;

import com.haxepunk.Entity;
import com.haxepunk.Graphic;
import com.haxepunk.graphics.Text;
import com.haxepunk.graphics.Image;
import flash.geom.Point;
import com.haxepunk.HXP;
import com.haxepunk.Scene;
import scenes.GameScene;

/**
 * ...
 * @author ... Marcelo Ruben Guardia
 */
class Mensaje extends Entity
{
	//private var msg:Graphic;
	private var lifeTime:Float;
	private var txt:Text;
	private var firstUpdate:Bool;

	override public function new(_msg:String, pos:Point, _lifeTime:Float) 
	{
		super(pos.x, pos.y);
		lifeTime = _lifeTime;
		
		var msg = _msg;
		#if flash //si es para plataforma flash
			var txtOptions  = { color:0x1ECE15, size:20, align: TextFormatAlignType.CENTER, font: "font/LinLibertine_R.ttf" };
		#else //si es para otra plataforma
			var txtOptions  = { color:0x1ECE15, size:20, align: "center", font: "font/04B_03__.ttf" };
		#end //cierro las opciones de plataformas
		
		// creando el texto con las opciones seteadas anteriormente
		txt = new Text(msg, txtOptions);
		firstUpdate = true;
	}
	
	override public function update():Void
	{
		super.update();
		if (firstUpdate)
		{
			scene.addGraphic(txt, 0, x, y);
			firstUpdate = false;
		}
	}
	
}